$(document).ready(function() {
    layui.use(['form'], function() {
        var form = layui.form
        form.on('submit(demo1)',function(data){
            $.ajax({
                type: "post",
                url: "/user/addUserInfo",
                dataType: "json",
                traditional: true,
                contentType : 'application/json;charset=utf-8',
                data:
                    JSON.stringify({
                        userName: $('#userName').val(),
                        sex: $('#sex').val(),
                        idCard: $('#idCard').val(),
                        phone: $('#phone').val(),
                        email: $('#email').val(),
                    }),
                success: function(res) {
                    console.log("添加成功");
                    layui.use('layer', function(){
                        var layer = layui.layer;
                        layer.msg('添加成功');
                        $('#userName').val('')
                        $('#sex').val('')
                        $('#idCard').val('')
                        $('#phone').val('')
                        $('#email').val('')
                    })
                }
            })
        })
    })
})